import request from '@/utils/request'

export function login(data) {
  return request({
    url: '/users/login',
    method: 'post',
    data
  })
}

export function getInfo(token) {
  return request({
    url: '/users/info',
    method: 'get',
    params: { token }
  })
}

export function logout() {
  return request({
    url: '/users/logout',
    method: 'post'
  })
}

export function fetchUserList(query) {
    return request({
        url: '/users/list',
        method: 'get',
        params: query
    })
}

export function fetchUser(id) {
    return request({
        url: `/users/${id}`,
        method: 'get'
    })
}

export function createUser(data) {
    return request({
        url: '/users/add',
        method: 'post',
        data
    })
}

export function updateUser(data) {
    return request({
        url: '/users/update',
        method: 'post',
        data
    })
}

export function deleteUser(id) {
    return request({
        url: `/users/delete/${id}`,
        method: 'delete'
    })
}